home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / roff4.arc / ROFF4.PRN < prev    next >
Encoding:
Text File  |  1985-08-10  |  51.9 KB  |  1,255 lines

  1.  
  2.     ROFF4 V1.61                                                Augest 3,1985
  3.  
  4.  
  5.                    ROFF4, V1.60                  ROFF4, V1.61
  6.  
  7.                by Ernest E. Bergmann          by Conrad Kwok
  8.                Physics, Building #16          20 3rd St.,Section M,
  9.                Lehigh University              Fairview Park,
  10.                Bethlehem, PA 18015            Hong Kong.
  11.  
  12.  
  13.  
  14.               ROFF4  is  an  expanded  version  of  ROFF,  based on the
  15.          formatter in Kernighan and Plauger's book SOFTWARE  TOOLS,  is
  16.          written  in BDS C. Now it is adapted on IBM PC using Microsoft
  17.          C.  Some of the input  files  may  be  used  to  "set-up"  the
  18.          formatter   for   a   particular   style  and  for  particular
  19.          hardware.   It  is  possible  to  substitute  keyboard   input
  20.          instead of files for educational and test purposes.
  21.  
  22.               95%  of the code of ROFF4 V1.61 is the same as V1.60. The
  23.          changes include:
  24.  
  25.          (1) Modification to run on IBM PC using Microsoft C  V1.04  or
  26.              Lattice  C  V1.04.  Most of the other C compiler should be
  27.              able to compile the program with minor modification.
  28.  
  29.          (2) Implementation of macro commmand with paramters.
  30.  
  31.          (3) Fixing some minor bugs.
  32.  
  33.          (4) Allow changing of character size on  the  same  line  with
  34.              superscript and subscript.
  35.  
  36.               ROFF  was  provided  by  Neal Somos for the public domain
  37.          via the BDS 'C' Users'  Group's  volume,  CUG  --  "Just  Like
  38.          Mom's".  Some of this documentation started there as well.
  39.  
  40.               This   formatter  contains  features  important  for  the
  41.          preparation of technical  manuscripts.    Special  symbols  or
  42.          fonts  that  can be defined by or for the user can be produced
  43.          (if the hardware is capable!).  Super and  subscripts  can  be
  44.          handled  as  well  as  backspace  even  for  printers  without
  45.          reverse  scrolling  or  backspacing   hardware   capabilities.
  46.          However,  the  output  device  should recognize separately the
  47.          <CR> and <LF> functions.  The Epson  MX-80  with  GRAFTRAX  80
  48.          was  used  by  the author for most of the development, however
  49.          he also was able  to  use  the  video  display  of  the  Exidy
  50.          Sorcerer, which  has  user definable graphics.  "Preprocessor"
  51.          directives can be used to merge stock phrases,  boiler  plate,
  52.          make   macro   definitions,  automate  numbering,  and  create
  53.          diversions (for footnotes, table of contents, etc.)
  54.  
  55.               To support the capabilities of WORDSTAR[tm  by  MicroPro]
  56.          extended   underlining,   strikeout,   and   multiple   strike
  57.          capability are provided as well.
  58.  
  59.          Sample calls:
  60.  
  61.          A>roff4 filename1 filename2 filename3 +)
  62.  
  63.  
  64.  
  65.                                                                     Page  1
  66.  
  67.  
  68.     ROFF4 V1.61                                                Augest 3,1985
  69.  
  70.  
  71.                  this would send the formatted version of  these  three
  72.                  files to the console and to the printer
  73.  
  74.          A>roff4 filename1 +)&filename2
  75.  
  76.                  this  would  format  filename1  and  send  it  to  the
  77.                  printer, console, and to filename2.
  78.  
  79.          A>roff4 -s -f filename1 -b filename2 -f -m -r -d -i -g -*
  80.  
  81.                  The option, -s, causes the formatter to  stop  (pause)
  82.                  at the  start of each page of output;  the bell at the
  83.                  console is sounded (if it  exists!)  and  the  program
  84.                  waits until  any key is pressed at the console.  It is
  85.                  essential for printers that are feed single sheets  at
  86.                  a time!
  87.  
  88.               I  do  not  use the redirection output feature of DOS 2.0
  89.          or higer because this feature  is  extremely  slow  (30  times
  90.          slower)  and the output will contain some unwanted characters.
  91.          Hence the symbol '&' is used for specifying  the  output  file
  92.          name.
  93.  
  94.               An  option  that  was not shown above, -o[page or range],
  95.          is  used  to  selectively  generate  output  of  ONLY  certain
  96.          pages.   It  is useful to retype pages that got "eaten" by the
  97.          printer (Henry Harpending's aptly put language).    To  retype
  98.          only page  23,  say, make the option:  -o23 To retype pages 23
  99.          through 29 use:  -o23-29 To retype pages 23 to  the  end  use:
  100.          -23-   These  options  changes  the  values  of  the  internal
  101.          variables, FIRSTPAGE and LASTPAGE which  originally  have  the
  102.          values of  1  and  30000,  respectively.  Normally this option
  103.          would be placed early enough  in  the  command  line  that  no
  104.          pages have been printed yet.
  105.  
  106.               The  option,  -f,  would  introduce a formfeed (0CH) into
  107.          the  output  stream  (useful  for  placing  blank  pages,   or
  108.          aligning printer  pages)  where  it appears;  in this example,
  109.          before the first page of output, and, again, at the  very  end
  110.          of the output.
  111.  
  112.               The  option, -b, turns on the "debug" flag so as to print
  113.          out lots of diagnostics  to  the  STDERR[console].    Probably
  114.          only  useful  for  those who are trying to trace the operation
  115.          of the formatter for elusive  bugs".  This  option  is  usable
  116.          only  when DEBUGON is defined during compilation. See the file
  117.          "ROFF4.H"
  118.  
  119.               The option, -m, causes a list of macro definitions to  be
  120.          typed to  the  console.    It  is  a useful tool for debugging
  121.          complex macro packages  where  the  preprocessor's  expansions
  122.          are too subtle for humans.
  123.  
  124.               The  option,  -d,  causes a list of diversion files to be
  125.          typed to the console.  Its main virtue is to remind  the  user
  126.          what files are being generated and their approximate size.
  127.  
  128.  
  129.  
  130.  
  131.                                                                     Page  2
  132.  
  133.  
  134.     ROFF4 V1.61                                                Augest 3,1985
  135.  
  136.  
  137.               The  option, -i, causes a list of string insertions to be
  138.          typed to the console.  Useful for macro writers,  as  was  the
  139.          -m, described  above.   Also, for noting what are the settings
  140.          of "standard substitutions", such as "today's date".
  141.  
  142.               The option, -r, causes a list of number registers  to  be
  143.          typed to  the  console.  Could be useful to find the number of
  144.          footnotes, etc.
  145.  
  146.               The option, -g, causes a glossary of  defined  translated
  147.          characters to  be  printed on the output device.  It is useful
  148.          to check the appearance of all  special  definable  characters
  149.          and   to   produce   a  "wall  chart"  of  special  characters
  150.          available.
  151.  
  152.               The default option, -*, (the * could  be  any  unassigned
  153.          option)  means  keyboard  input  (buffered line-by-line with a
  154.          prompt with  the  character  used  in  the  option,  here  *).
  155.          Typing a  control-Z  indicates  an end-of-file;  the formatter
  156.          will continue with the next named file.  It is intended  as  a
  157.          learning  aid  since  one  can  tryout  "tricky" input such as
  158.          equations.  As with standard CP/M, a control-P can be used  to
  159.          toggle  the  printer  to display output that would normally be
  160.          sent to the console;  also, one can edit  the  keyboard  input
  161.          with the backspace key.
  162.  
  163.               Using  ROFF4, you can make nice printouts of a file, with
  164.          as little or as much  help  from  the  program  as  you  want,
  165.          depending on  the  commands.  There are default values for all
  166.          parameters, so if you don't put any commands in at  all,  your
  167.          file will  come  out  with filled, right-justified lines.  The
  168.          default line-length is  60  characters;    the  default  page-
  169.          length is  66  lines  per  page.  "Filled lines" means that as
  170.          many input words as possible are packed onto a line before  it
  171.          is printed;    "non-filled" lines go through the formatter w/o
  172.          rearrangement.  "Right-justified"  simply  means  that  spaces
  173.          are  added between words to make all the right margins line up
  174.          nicely.  To set a  parameter,  use  the  appropriate  commands
  175.          below.  All commands have the form of a period followed by two
  176.          letters. A command line should have  nothing  on  it  but  the
  177.          command and its arguments (if any);  any text would be lost.
  178.  
  179.               Extra space  will  separate text sentences.  The sentence
  180.          is recognized by a trailing ':',';','!','?', or a  '.'.    For
  181.          the  '.'  there  is the additional requirement that either two
  182.          or more spaces must spaces must follow it, or that  it  is  at
  183.          the end of the source line.
  184.  
  185.               A command argument can be either ABSOLUTE or RELATIVE :
  186.  
  187.           .in     5       sets the indent value to 5 spaces
  188.           .in     +5      sets the indent value to the CURRENT value+5
  189.           .ls     -1      sets the line spacing to the current value-1
  190.  
  191.               Also,  all commands have a minimum and maximum value that
  192.          will weed out any odd command settings (like setting the  line
  193.          spacing  to  zero,  for example. It won't let you do that, but
  194.          it could be changed if you REALLY have a burning desire to  do
  195.  
  196.  
  197.                                                                     Page  3
  198.  
  199.  
  200.     ROFF4 V1.61                                                Augest 3,1985
  201.  
  202.  
  203.          so).
  204.  
  205.               Some  commands  cause  a  "break",  which is noted in the
  206.          table below.  Before such a  command  goes  into  effect,  the
  207.          current  line  of  text  is  put out, whether it is completely
  208.          filled or  not.  (this  is  what  happens  at  the  end  of  a
  209.          paragraph,  for  example.)  A  line beginning with spaces or a
  210.          tab will cause a break, and will  be  indented  by  that  many
  211.          spaces  (or  tabs) regardless of the indent value at that time
  212.          (this  is  a  "temporary  indent",  which  can  also  be   set
  213.          explicitly).  An  all  blank line also causes a break.  If you
  214.          find that some lines that are  indented  strangely,  and  it's
  215.          not  obvious  WHY, look at which commands are causing a break,
  216.          and which aren't. For instance:
  217.  
  218.           .fi
  219.           .ti 0
  220.           this is a line of text
  221.           .in 8
  222.                                                  <- blank line
  223.           more text for the machine to play with
  224.  
  225.               At first glance it seems obvious that the line  "this  is
  226.          a  line  of text" will be indented zero spaces, but it won't -
  227.          it will be indented 8. The indent command  does  NOT  cause  a
  228.          break  (although  the  .ti does) so it will not cause the line
  229.          to be put out before setting the indent value  to  8.    Then,
  230.          when  the  blank  line is encountered, it will cause a break -
  231.          and "this is a line of text"  will  be  indented  incorrectly.
  232.          The above example will give the following lines.
  233.  
  234.                  this is a line of text
  235.  
  236.                  more text for the machine to play with
  237.  
  238.               It  is  worthwhile considering placing a ".br", the break
  239.          command, before each use of ".in";  should future versions  of
  240.          ROFFn have the break already part of the indent command?
  241.  
  242.               Certain   system   variables   are  "stacked"  to  enable
  243.          reversion  to  earlier  environments  instead  of  "hardcoded"
  244.          defaults.  For example:
  245.  
  246.           .ls 1
  247.            .
  248.            .
  249.           .ls
  250.  
  251.          The  first  command will produce single line spacing (which is
  252.          the default, but which may have  been  set  otherwise  at  the
  253.          beginning of  the  manuscript).    The  second  command causes
  254.          resumption of the original line spacing  (either  the  default
  255.          or whatever  had  been  chosen previously).  Stacked variables
  256.          include:    linespacing,   indent   column,   right    margin,
  257.          translation  flag  character,  page  length,  top  and  bottom
  258.          margin sizes,  unexpandable  space  character,  output  width,
  259.          tabsize, and control flag character.
  260.  
  261.  
  262.  
  263.                                                                     Page  4
  264.  
  265.  
  266.     ROFF4 V1.61                                                Augest 3,1985
  267.  
  268.  
  269.          *********************** Table of Commands *********************
  270.  
  271.           Command       Break?    Default stacked Function
  272.           -------       ------    ------- ------- ---------
  273.           .. string       no                      string is "mere"comment
  274.  
  275.           .ab             no                      immediate abort back to
  276.                                                   system
  277.  
  278.           .bj             yes                     break with right
  279.                                                   justification (current
  280.                                                   line only)
  281.  
  282.           .bp n           yes     n =  +1         begin page numbered n
  283.  
  284.           .br             yes                     cause a break (this
  285.                                                   line is not justified)
  286.  
  287.           .cf c           no      c = '^' Yes     to be used as a prefix
  288.                                                   to a character that
  289.                                                   controls print func-
  290.                                                   tions such as ^+,^-
  291.                                                   might be used to
  292.                                                   bracket superscripts,
  293.                                                   somewhat like
  294.                                                   WORDSTAR(TM).
  295.  
  296.           .ce n           yes     n = 1           center next n lines
  297.  
  298.           .db n           no      n = 0(NO)       set debug flag 1 for
  299.                                                   diagnostics
  300.  
  301.           .di name        no      JUNK.$$$        diversion file
  302.                                                   (see "PREPROCESSOR")
  303.  
  304.           .dm name        no                      define (multiline)
  305.                                                   macro ("PREPROCESSOR")
  306.  
  307.           .ds /../../../  no      null string     define string replace-
  308.                                                    ment ("PREPROCESSOR")
  309.  
  310.           .ed             no                      end diversion
  311.                                                   (see "PREPROCESSOR")
  312.  
  313.           .ef /../../../  no      blanks          even footer titling
  314.  
  315.           .eh /../../../  no      blanks          even header titling
  316.  
  317.           .em                                     end macro
  318.                                                   (see "PREPROCESSOR")
  319.  
  320.           .fi             yes                     start filling lines
  321.  
  322.           .ff n           no      n = 1(yes)      initially, formfeeds
  323.                                                   are "off". Can turn
  324.                                                   them on.  Each page
  325.                                                   then terminated with
  326.                                                   one formfeed.
  327.  
  328.  
  329.                                                                     Page  5
  330.  
  331.  
  332.     ROFF4 V1.61                                                Augest 3,1985
  333.  
  334.  
  335.           .fo /../../../  no      empty           sets both even and odd
  336.                                                   page footers
  337.  
  338.           .fr # base - ;  no      1,no action     defines how to put
  339.           - - - - .                               output device in mode
  340.                                                   for fractional line
  341.                                                   spacing(for super,sub-
  342.                                                   scripting);see details
  343.                                                   given below. Comple-
  344.                                                   ments .WH, below.
  345.  
  346.           .he /../../../  no      empty           sets both even and odd
  347.                                                   page headers
  348.  
  349.           .ic c           no      c = '\' Yes?    to specify the char-
  350.                                                   acter used for macro
  351.                                                   preprocessing to denote
  352.                                                   the token that follows.
  353.  
  354.           .ig string      no                      "ignore" string(see ..)
  355.  
  356.           .in n           no      n = 10  Yes     set indent value to n
  357.  
  358.           .ju             no      initially on    turn on right justifi-
  359.                                                   cation (only applicable
  360.                                                   if "filling" also)
  361.  
  362.           .ls n           no      n = 1   Yes     set line spacing to n
  363.  
  364.           .m1             no      n = 2   Yes     set topmost margin to n
  365.  
  366.           .m2             no      n = 2   Yes     set 2nd top margin to n
  367.                                                   lines
  368.  
  369.           .m3             no      n = 2   Yes     1st bottom margin to n
  370.                                                   lines
  371.  
  372.           .m4             no      n = 2   Yes     bottom-most margin to n
  373.                                                   lines
  374.  
  375.           .ne n           no/yes  n = 2           "need" n lines; if have
  376.                                                   them no action; else
  377.                                                   begins new page
  378.  
  379.           .nf             yes                     stop filling lines
  380.  
  381.           .nj             no      initially       turn off right justi-
  382.                                   is justifying   fication (only relevent
  383.                                                   if "filling" also)
  384.  
  385.           .of /../../../  no      empty           odd page footer title
  386.  
  387.           .oh /../../../  no      empty           odd page header title
  388.  
  389.           .ou base - - ;  no      not applicable  direct output of code
  390.           - - - .                                 sequences to output.
  391.  
  392.  
  393.  
  394.  
  395.                                                                     Page  6
  396.  
  397.  
  398.     ROFF4 V1.61                                                Augest 3,1985
  399.  
  400.  
  401.           .ow             no      n = 80          sets output width for
  402.                                                   header and footer title
  403.  
  404.           .pc c base - ;  no      not applicable  used to create
  405.           - - - .                                 definitions for special
  406.                                                   printer controls, such
  407.                                                   as for italics.
  408.  
  409.           .pl n           no      n = 66  Yes     sets page length to n
  410.  
  411.           .rg name n      no      n=0     No      create or modify
  412.                                                   register variable
  413.                                                   (see "PREPROCESSOR")
  414.  
  415.           .rm n           no      n = 70  Yes     sets right margin to n
  416.  
  417.           .sa string                              "say": message to
  418.                                                   console; like a comment
  419.                                                   but displayed to
  420.                                                   operator during run.
  421.  
  422.           .sc c           no      blank   Yes     space character; the
  423.                                                   visible character
  424.                                                   that will be trans-
  425.                                                   literated to unexpanded
  426.                                                   blank.
  427.  
  428.           .so filename    no      ignored Yes     reads named file into
  429.                                                   input stream; cannot be
  430.                                                   invoked from keyboard
  431.                                                   input.
  432.  
  433.           .sp n           yes     n = 1           space down n lines
  434.  
  435.           .st n           no      n=1(yes)        stop(pause)at each page
  436.                                                   start; initially off;
  437.                                                   may also be enabled by
  438.                                                   the -s option.
  439.  
  440.           .tc c           no      ~       Yes     set translation flag
  441.                                                   character, see .tr
  442.  
  443.           .tr c base - ;  no      not applicable  used to create
  444.           - - - .                                 definitions for special
  445.                                                   character fonts.
  446.  
  447.           .ts n           no      n = 8   Yes     sets value of tab space
  448.  
  449.           .ti n           yes     n = 0           set temp. indent of n
  450.  
  451.           .wh             no      no action       instructs how to resume
  452.                                                   whole line spacing;
  453.                                                   complements .FR, above.
  454.  
  455.            -------------------------------------------------------------
  456.  
  457.  
  458.  
  459.  
  460.  
  461.                                                                     Page  7
  462.  
  463.  
  464.     ROFF4 V1.61                                                Augest 3,1985
  465.  
  466.  
  467.          Here's what the page parameters look like:
  468.  
  469.                  |<--------output width (.ow)------------------->|
  470.  
  471.          _       _________________________________________________
  472.          |       |       top margin(m1) - (includes header)      |
  473.          |       |-----------------------------------------------|
  474.          |       |               top margin 2                    |
  475.          |       |-----------------------------------------------|
  476.          P       |       :                               :       |
  477.          A       |       :<-indent                       :       |
  478.          G       |       :                               :       |
  479.          E       |       :lots and lots of silly text and:       |
  480.          L       |       :other garbage. Get the picture?:       |
  481.          E       |          :This is a temp.  indentation:       |
  482.          N       |       :                               :       |
  483.          G       |       :               right margin -> :       |
  484.          T       |       :                               :       |
  485.          H       |       :                               :       |
  486.          |       |-----------------------------------------------|
  487.          |       |               margin 3                        |
  488.          |       |-----------------------------------------------|
  489.          |       |  margin 4 - (includes footer,perhaps ff)      |
  490.          -       -------------------------------------------------
  491.  
  492.          Minimum acceptable  values  for  M1, M2, M3, and M4;  if M1 is
  493.          set to zero,  no  header  will  be  shown  (even  if  one  was
  494.          declared).   Similarly,  if  M4 is set to zero, no footer will
  495.          be displayed.
  496.  
  497.               To change the default for  any  parameter,  simply  alter
  498.          ROFF4.H and reExecute COMPILE.BAT.
  499.  
  500.          ************************************************************
  501.          A Few Extra Comments on Some of the Commands:
  502.          ************************************************************
  503.  
  504.               If you want to center lots of lines, but don't
  505.          want to count them, do something like this:
  506.  
  507.           .ce     1000
  508.           lots and
  509.           lots of words to
  510.           be centered
  511.           .ce 0
  512.  
  513.          will give the lines:
  514.                                    lots and
  515.                                lots of words to
  516.                                   be centered
  517.  
  518.                  --------------------------------------
  519.  
  520.  
  521.               A  new  paragraph  may  be  caused by using the temporary
  522.          indent command, like
  523.  
  524.           .ti +5
  525.  
  526.  
  527.                                                                     Page  8
  528.  
  529.  
  530.     ROFF4 V1.61                                                Augest 3,1985
  531.  
  532.  
  533.          or by simply beginning the paragraph with a tab, as you  would
  534.          if you were just typing.
  535.  
  536.                  ------------------------------------
  537.  
  538.  
  539.               For  special  cases,  where  you  wish  to place the last
  540.          "word" at the right-hand margin, such as numbers of  equation,
  541.          for example:
  542.                                    x = y+z                         (12)
  543.          you could input:
  544.          # x#=#y+z (12)
  545.          .bj
  546.          because we force a break with justification (.bj) of the  line
  547.          with  only  "three  words". (The # is assumed to be the "space
  548.          character" set up with a .sc command).
  549.  
  550.                  ------------------------------------
  551.  
  552.                              Headers and Footers.
  553.  
  554.               A page number can be  incorporated  into  any  header  or
  555.          footer  by  putting  a  "#"  in  the  title where you want the
  556.          number to go:
  557.           .he     /This is a witty header title for page #/
  558.          Each time this is printed at the top of a  page,  the  current
  559.          page number  will be substituted for the "#".  Each footer and
  560.          header are ".in 0", even if text is indented.
  561.  
  562.               Headers and footers are in three parts.  These parts  are
  563.          left justified,  centered,  and  right justifed.  Any of these
  564.          three parts may be left  out.    The  right  justification  is
  565.          fixed to  the  margin that is set by the .OW command.  One may
  566.          pick the headers and  footers  separately  for  even  and  odd
  567.          pages.   For  example,  one  could  place  even  and  odd page
  568.          numbers at the bottom outside of each page by:
  569.           .ef /Page #///
  570.           .of ///Page #/
  571.  
  572.  
  573.               Any printable character, here the '/',  can  be  used  to
  574.          delimit  the three strings that make up the titles, so long as
  575.          it is not the "insert character" (usually,  '\')  and  is  not
  576.          present in any of the three strings.
  577.  
  578.               The  program can be made to wait for the operator to load
  579.          single sheets  of  paper  by  the  -s  option  and/or  by  the
  580.          command:  .st
  581.  
  582.                  ------------------------------------
  583.  
  584.               If  you want to send the output to a file, and don't want
  585.          the page breaks in there set margins 1-4 to zero.
  586.  
  587.                  ------------------------------------
  588.  
  589.  
  590.  
  591.  
  592.  
  593.                                                                     Page  9
  594.  
  595.  
  596.     ROFF4 V1.61                                                Augest 3,1985
  597.  
  598.  
  599.               Where you need to supply code sequences for immediate  or
  600.          for  subsequent  output  (for  .ou  or  for  .tr) one needs to
  601.          supply  the  number   base   (binary,   octal,   decimal,   or
  602.          hexadecimal)  by supplying a token that begins with (upper and
  603.          lowercase are both o.k.):  b, o(or q), d, or h. Following  the
  604.          base  on  the  same  and/or  subsequent lines one supplies the
  605.          codes that will  form  the  "code  string".  These  codes  are
  606.          delimited  by  white  space  (not commas!) and the sequence is
  607.          eventually terminated by a  token  beginning  with  a  period.
  608.          The  ends  of  any of these lines may contain comments if they
  609.          are set off by white space and a semicolon. For examples:
  610.           .ou hex 11 1C 8C 0
  611.           99 6C 55 ;get ready!
  612.           .end
  613.  
  614.           .TR = binary ;"identity"operator (triple equal sign) on MX-80
  615.           00011011 ;ESC
  616.           01001011 ;4B
  617.           00000110 ;6 bit patterns
  618.           0        ;follow:
  619.           00101010 ;left top,bot
  620.           00101010
  621.           00101010
  622.           00101010
  623.           00101010
  624.           00000000 ;right top,bot
  625.           .en
  626.  
  627.               The first of these examples might be  used  to  get  some
  628.          strange  printer  to  cooperate  in  standing  on  its head or
  629.          something.
  630.  
  631.               The second, lengthier example is taken from a  file,  MX,
  632.          that  defined  quite  a  number  of special characters for the
  633.          MX-80 with  GRAFTRAX  80.    Because  that  printer  uses  dot
  634.          graphics,  I  chose  to  make the definition in binary so that
  635.          the placement of the individual dots is easier  to  visualize.
  636.          Later, in  the  text  the  combination:    ~=  will  cause the
  637.          printer to be sent  this  code  so  that  it  will  print  the
  638.          specialized symbol.
  639.  
  640.  
  641.                                SPECIAL SYMBOLS
  642.  
  643.               If  one  includes  a set of definitions such as in the MX
  644.          file, one can specify the use of special  symbols,  which  can
  645.          be  chosen  to  fit  the  application  (and the hardware!) For
  646.          example, the MX-80  printer  equipped  with  GRAFTRAX  80  can
  647.          accept dot  addressed graphics.  [See the MX file for examples
  648.          with this hardware].  Other printers may be able  to  simulate
  649.          symbols by  a  combination  of  overstruck  characters.  Still
  650.          other output devices may  be  capable  of  displaying  desired
  651.          special symbols by use of the "parity bit".
  652.  
  653.               The  .tr  and  .tc  commands  define  the  codes  for the
  654.          special symbols and the translation character.   To  create  a
  655.          "wall  chart"  that lists the special characters on the output
  656.          device you could use the -g option on the  command  line,  for
  657.  
  658.  
  659.                                                                    Page  10
  660.  
  661.  
  662.     ROFF4 V1.61                                                Augest 3,1985
  663.  
  664.  
  665.          example:
  666.          A>roff4 mx -g )
  667.  
  668.  
  669.                      ====================================
  670.  
  671.  
  672.                                 PRINTER CONTROL
  673.  
  674.               It  is assumed that the output device can accept carriage
  675.          returns and will not linefeed in the absence of  the  linefeed
  676.          character.   Using  this  assumption, super- and subscripting,
  677.          backspacing,    underscoring,    strickout,    and    multiple
  678.          impressions  are  supported  in a manner somewhat analogous to
  679.          WORDSTAR [tm by MicroPro], but more generally.
  680.  
  681.               If the printer can be placed  in  fractional  linespacing
  682.          mode,  so much the better, as full line spacing for super- and
  683.          subscripts does not look as "natural".  Also,  with  the  half
  684.          line  spacing,  one  can  build  up larger characters (such as
  685.          summation and integration symbols)  since  some  overlap  does
  686.          occur.   To  implement  such  fractional  spacing one uses the
  687.          commands, .fr and .wh (probably at the beginning of the  input
  688.          file,  along  with  other  information  relevent to the output
  689.          device and style).  These commands  describe  the  operational
  690.          codes  sent  to the output to switch the printer to FRactional
  691.          spacing and back to WHole line spacing.
  692.  
  693.               For example, I use for the MX-80  printer  equipped  with
  694.          GRAFTRAX 80 the following:
  695.  
  696.           .WH HEX 1B 32 . ; 6 lines/inch is standard
  697.           .fr 2 hex 1b 33 12 . ; 18/216" = halfline spacing
  698.  
  699.          The  initial  2  in .fr tells the formattter that 2 fractional
  700.          [half] lines are equivalent  to  a  conventional  whole  line.
  701.          The  original  description  of  the  required  codes  were  in
  702.          hexadecimal, so I kept matters as simple as possible by  using
  703.          the  same  number base so that I would not make any conversion
  704.          mistakes!
  705.  
  706.               The printer control requests are embedded  in  the  text;
  707.          they  are  NOT set off in separate lines as the "dot" commands
  708.          are set apart.  Each request  is  made  up  of  two  printable
  709.          characters,   the   first   of  which  is  the  "control  flag
  710.          character" (the default is '^').  Here is a table  of  control
  711.          functions   presently   supported   by  ROFF4,  version  1.30:
  712.          (additional codes can be created with  the  "printer  control"
  713.          command, .pc)
  714.  
  715.  
  716.          ^+      up a  fractional  line;   may be used several times to
  717.                  increase  vertical  rise.  [used   at   start   of   a
  718.                  superscript and at the end of a subscript]
  719.  
  720.          ^-      down a  fractional line;  may be used several times to
  721.                  increase vertical  drop.  [used  at  the  start  of  a
  722.                  subscript and at the end of a superscript]
  723.  
  724.  
  725.                                                                    Page  11
  726.  
  727.  
  728.     ROFF4 V1.61                                                Augest 3,1985
  729.  
  730.  
  731.          ^h,^H   backspace one  character  column.    Do  NOT backspace
  732.                  over ordinary blanks ("unexpandable"  space  is  o.k.)
  733.                  if you are in "fill" mode.
  734.  
  735.          ^(,^)   Note current column position; return to noted position.
  736.          ^[,^]   "       "       "       "       "       "       "
  737.          ^{,^}   "       "       "       "       "       "       "
  738.  
  739.                  The  above  three  pairs  of  controls  are often more
  740.                  convenient then  multiple,  explicit  backspaces,  ^H,
  741.                  especially for "built-up" fractions and matrices.
  742.  
  743.          ^B,^b   Start,  end boldface (increase, decrease the number of
  744.                  impressions by a factor of 3).
  745.  
  746.          ^D,^d   Start,  end  doublestrike  (increase,   decrease   the
  747.                  number of impressions by a factor of 2).
  748.  
  749.          ^U,^u   Start,  end underscore (will not underscore expandable
  750.                  white space;  will ride up and  down  with  super  and
  751.                  subscripts.)
  752.  
  753.          ^X,^x   Start,  end  strikeout  (similar to underscore, above,
  754.                  but overprints with '-' instead of underlines).
  755.  
  756.  
  757.               Note  that  the  last  4  pairs  are  "case   sensitive";
  758.          namely,  the  uppercase  starts  some  activity,  whereas  the
  759.          lowercase equivalent sqelches it;    these  controls  are  NOT
  760.          "toggles".
  761.  
  762.               An  involved example of the use of printer controls would
  763.          be to create a 3 by 3 matrix:
  764.  
  765.          MATRIX =#^+^+^(|1#2#3|^)^-^-|4#5#6|^)^-^-|7#8#9|^+^+
  766.  
  767.          which should produce (with a half-spacing) printer:
  768.  
  769.                   |1 2 3|
  770.          MATRIX = |4 5 6|
  771.                   |7 8 9|
  772.  
  773.          [the demonstration  file,  MATRIX,  has  been  provided  as  a
  774.          demonstration of the above].
  775.  
  776.               Several points  should  be  observed.  There should be no
  777.          expandable blank spaces if you are in  fill  mode,  otherwise,
  778.          the result  might be very strange!  (ROFF4 does some checks to
  779.          flag such attempts). We are assuming here  that  the  '#'  are
  780.          unexpandable spaces  (chosen with the .sc command).  The first
  781.          printable character  in  the  complex,  the  '=',  is  at  the
  782.          leftmost edge;      the  last  printable  character,  the  '|'
  783.          following  the  '9',  is  at  the  rightmost  edge   of   this
  784.          assemblage.   The  final  height  is adjusted (by the trailing
  785.          ^+^+ ) to match the initial height.  The present limit of  the
  786.          line buffering  is  255  characters;  I assume that is not too
  787.          chancy.
  788.  
  789.  
  790.  
  791.                                                                    Page  12
  792.  
  793.  
  794.     ROFF4 V1.61                                                Augest 3,1985
  795.  
  796.  
  797.               One can define additional  printer  control  codes  using
  798.          the .pc   command.    For  example,  the  MX-80  printer  with
  799.          Graftrax is switched to italics with the sequence  <ESC>  '4';
  800.          and italics  are  turned  off with <ESC> '5'.  We could define
  801.          ^I to start italics and ^i to end them:
  802.  
  803.           .pc I hex ;italics on (MX-80   Graftrax)
  804.           1B 34
  805.           .en
  806.           .pc i hex ; italics off (MX-80   Graftrax)
  807.           1B 35
  808.           .en
  809.  
  810.  
  811.                        ================================
  812.  
  813.                                THE PREPROCESSOR
  814.  
  815.               In  the  following  we  describe   the   advanced   macro
  816.          preprocessing  features  of this formatter which provide users
  817.          with labor saving tools but which are probably  not  necessary
  818.          at first.    The  beginning  user  may be able to achieve most
  819.          goals without the "preprocessing",  but  by  using  an  editor
  820.          more then  otherwise.    The  more advanced user will begin to
  821.          appreciate these features more.
  822.  
  823.               In the following discussion we will  assume  the  default
  824.          insert  character,  '\',  and  the  default command character,
  825.          '.', will be used.  (It is rare that you should  change  these
  826.          anyway!)
  827.  
  828.               The   insert   character   is  used  to  denote  where  a
  829.          replacement should be used.  For example, in:
  830.  
  831.          Today, \date\, is special.
  832.  
  833.          the block, "\date\", would be replaced  as  this  sentence  is
  834.          being input.  If a prior string definition of the form:
  835.  
  836.           .ds *date*January 1, 1983*
  837.  
  838.          had  been  processed  previously  then the example, after text
  839.          substitution, would become:
  840.  
  841.          Today, January 1, 1983, is special.
  842.  
  843.               The string definition  command,  .ds,  expects  that  the
  844.          first  visible  character, here a '*', is the delimiter of the
  845.          start and end ot  the  two  parts  in  the  definition;    any
  846.          printable  character  (that  is not present in either string!)
  847.          may be used.
  848.  
  849.               If no string definition had  been  provided  for  "date",
  850.          the  user  will  be  prompted while the formatter is trying to
  851.          input this sample line.  The console  will  get  some  message
  852.          like:
  853.  
  854.          [Bell]Please define <date>:
  855.  
  856.  
  857.                                                                    Page  13
  858.  
  859.  
  860.     ROFF4 V1.61                                                Augest 3,1985
  861.  
  862.  
  863.               Whatever  you type in will be used to form an "effective"
  864.          .ds definition.     This   feature   should   be   useful   in
  865.          applications  where  information  should be changed or updated
  866.          each time the formatter is run,  such  as  today's  date,  the
  867.          addressee's name  and address in a form letter, etc.  A sample
  868.          file, FORM is included to demonstrate both of the above  means
  869.          to define string substitutions.
  870.  
  871.               An  important  restriction  must  be  observed when using
  872.          "definitions on the run".  They must not be first used  inside
  873.          of multiline definitions (namely inside of .ou, .tr,
  874.           .dm,  .pc,  .wh,  and  .fr)  because  the  building  of  both
  875.          definitions will cause them  to  interfere  with  each  other.
  876.          ROFF4,  v1.6 will test for such contention and abort operation
  877.          if one is found.  An example  of  such  a  situation  and  its
  878.          remedy is shown below:
  879.           .sa chose 0 for DRAFT and 1 for CORRESPONDENCE
  880.           .ou hex
  881.           1B
  882.           3\font\
  883.           .end .ou
  884.  
  885.               This  example,  which  might  be  used  to initialize the
  886.          Okidata  Microline  92  printer  to  go  into   correspondence
  887.          quality  or  into  draft quality printing would cause problems
  888.          if "font" is supposed to be  defined  here  during  execution.
  889.          We  are  in  the  midst  of  defining an output string for the
  890.          printer (ESC "0" or ESC "1")  when  we  are  asking  ROFF4  to
  891.          create (simultaneously)  a definition for "font";  the program
  892.          will abort rather  than  continue  with  the  two  definitions
  893.          mangling each  other.    Here  is  a modified version of above
  894.          without the problem:
  895.  
  896.           .sa chose 0 for DRAFT and 1 for CORRESPONDENCE
  897.           .. this comment containing \font\ is "ignored"
  898.           .ou hex
  899.           1B
  900.           3\font\
  901.           .end .ou
  902.  
  903.               The  fix  here  is  that  the  formatter  will  encounter
  904.          "\font\"  in  the comment and complete a definition for "font"
  905.          before takling the .ou command;  no simultaneous  definitions,
  906.          no problems!
  907.  
  908.               Similar  to  string  definitions  are register variables,
  909.          which  are  created  and  modified  with  the   .rg   command.
  910.          Variables   are   useful  for  enumeration  such  as  equation
  911.          numbering:
  912.  
  913.           .rg eqnum 1
  914.  
  915.          would create a register named "eqnum" with the  current  value
  916.          of 1.  The the text might use it with, say:
  917.  
  918.                   x = y+1 (\eqnum\)
  919.  
  920.          which would be converted on input into:
  921.  
  922.  
  923.                                                                    Page  14
  924.  
  925.  
  926.     ROFF4 V1.61                                                Augest 3,1985
  927.  
  928.  
  929.                   x = y+1 (1)
  930.  
  931.          A subsequent instruction:
  932.  
  933.           .rg eqnum +1
  934.  
  935.          would  take  the current value of "eqnum" and increase it by 1
  936.          (so that it would now be 2 in our example:
  937.  
  938.                   a = b+c (\eqnum\)
  939.  
  940.          would become:
  941.  
  942.                   a = b+c (2)
  943.  
  944.               There is a special, reserved insertion, \#\,  which  will
  945.          provide the  current  page  number.  It should prove useful in
  946.          setting up  tables  of  contents  (see  "diversions",  below).
  947.          Trivial  examples  of  its  use  are to be found in the files,
  948.          BPTEST and MARGINS.  In rare cases it  may  be  off  one  page
  949.          because it  may  be  read  while  between  pages;  how can one
  950.          handle the sentence, "This sentence is on page XXX," when  the
  951.          sentence straddles two pages?
  952.  
  953.               Since  we  have  defined a special register name, '#', we
  954.          should comment on  what  happens  if  you  create  a  register
  955.          instruction with that name, such as:
  956.  
  957.           .rg # +1
  958.  
  959.          You  will  be  changing  the  value  of the page number of the
  960.          FOLLOWING pages.  This is  useful  for  leaving  gaps  in  the
  961.          pagination  for  later  inclusion  of full page illustrations.
  962.          This feature is demonstrated (tested) in  the  file,  MARGINS.
  963.          I wish to thank Henry Harpending for suggesting this.
  964.  
  965.               The insert  character  has  other properties.  The insert
  966.          character can be  placed  into  the  input  by  repeating  it,
  967.          namely, "\\"    becomes    "\".       (useful   for   delaying
  968.          substitutions).  For example, defining:
  969.  
  970.           .ds 'EN'(\\eqnum\\)'
  971.  
  972.          will identify  "EN"  with  "(\eqnum\)"  and  so  our  equation
  973.          example above could have been:
  974.  
  975.                   a = b+c \EN\
  976.  
  977.          Delaying  the  evaluation  of  "eqnum"  until  EN  is  invoked
  978.          (instead of  when  it  was  defined)  means  that  the  proper
  979.          numbering   of   equations   will  occur  instead  of  wrongly
  980.          supplying the value of "eqnum"  from  the  time  that  EN  was
  981.          first created.
  982.  
  983.               If  the  insert  character  is  at  the end of a line, it
  984.          negates the following newline sequence;  thus  the  next  line
  985.          is merged with the current line.  For example:
  986.  
  987.  
  988.  
  989.                                                                    Page  15
  990.  
  991.  
  992.     ROFF4 V1.61                                                Augest 3,1985
  993.  
  994.  
  995.          antidisestab\
  996.          lishmentarianism
  997.  
  998.          is equivalent to:
  999.  
  1000.          antidisestablishmentarianism
  1001.  
  1002.               "Macro"  definitions  are  used  when we wish to identify
  1003.          several lines  with  an  insertion.    Such  definitions   are
  1004.          created  with  the .dm ["define macro"] and completed with the
  1005.          .em ["end macro"] commands.  For example,  we  might  wish  to
  1006.          use  the  following  sequence over and over again at the start
  1007.          of paragraphs:
  1008.  
  1009.           .sp 1
  1010.           .ne 2
  1011.           .ti +5
  1012.  
  1013.               to separate the paragraphs  by  blank  lines,  keep  them
  1014.          from  starting  excessively  close  to the bottom of the page,
  1015.          and indenting them 5 spaces to the right of the  current  left
  1016.          margin.   We might want to define the "command" as "paragraph"
  1017.          [personally, I might call it "P", because it would be  used  a
  1018.          lot and my typing ...]:
  1019.  
  1020.           .dm paragraph
  1021.           .sp 1
  1022.           .ne 2
  1023.           .ti +5
  1024.           .em
  1025.  
  1026.               Subsequently,  whenever we wished to start a paragraph we
  1027.          would creat a command line:
  1028.  
  1029.           .paragraph
  1030.  
  1031.          instead of  more  tediously  creating  every  time  the  three
  1032.          commands we mentioned above.
  1033.  
  1034.               The  names  of  all macros, strings, and number registers
  1035.          are "case sensitive".  That  is  to  say  that  capitalization
  1036.          and/or lower case are distinguished and, say,
  1037.  
  1038.           .Paragraph
  1039.  
  1040.          Would  not  be  recognized  as the same as the sample macro we
  1041.          just defined.  However, all  the  "built-in"  commands,  those
  1042.          which   were  listed  in  the  command  table,  are  not  case
  1043.          sensitive and are recognized on the first two  letters  alone,
  1044.          even if  arbitrary  letters or numbers follow immediately.  If
  1045.          we had a line:
  1046.  
  1047.           .time
  1048.  
  1049.          it would be identified with a "time" macro definition, if  one
  1050.          had been  created;    It  would  not be confused with a "Time"
  1051.          macro definition.  If there is no "time" macro, then it  would
  1052.          be matched with the "built-in", .TI ["temporary indent"].
  1053.  
  1054.  
  1055.                                                                    Page  16
  1056.  
  1057.  
  1058.     ROFF4 V1.61                                                Augest 3,1985
  1059.  
  1060.  
  1061.               A macro command may contain parameters(s). For example
  1062.  
  1063.           .dm HEADING
  1064.           .sp 2
  1065.           ^B$0^b
  1066.           .sp 2
  1067.           .em
  1068.          defines  a macro for printing heading. When the line ".HEADING
  1069.          Heading"  appear  on  the  beginning  of  a  line,  the   word
  1070.          "Heading"  will  be  printed  in boldface with two blank lines
  1071.          above and below. i.e.
  1072.  
  1073.  
  1074.          Heading         Heading         Heading
  1075.  
  1076.  
  1077.  
  1078.               The maximum number  of  parameters  for  a  macro  is  10
  1079.          ($0-$9).   The  parameter(s)  must  be on the same line of the
  1080.          macro call.      The   parameters   are    separate    by    a
  1081.          non-alphanumeric  character except '+' and '-' which appear as
  1082.          the first character  of  the  parameter  line.  If  the  first
  1083.          character  is  a alphanumeric character, then white space will
  1084.          be assumed as the delimiter. An example can  be  found  above.
  1085.          If  the  require  parameter(s) is/are not defined by the macro
  1086.          call, then the parameter(s) will be treated as null string.
  1087.  
  1088.               There is another object formed and used somewhat  like  a
  1089.          macro;   it  is  called a "diversion (file)" and is useful for
  1090.          making lists such as  references  [footnotes]  and  tables  of
  1091.          contents.   A  diversion  is  created  or  continued  with the
  1092.          commands:  .DI  [diversion]  and  .ED  [end  diversion].     A
  1093.          diversion  can  grow to be quite large and is, in fact, a disk
  1094.          file.  To "regurgitate" the diversion file, its  name  can  be
  1095.          placed  in  the  original  command  line, along with the other
  1096.          input file names;  alternatively, files can be retrieved  with
  1097.          the .SO  ["source"]  command.    The advantage of using .SO is
  1098.          that inclusion can be accomplished without a page  break,  nor
  1099.          even a line break between input files.  The
  1100.           .SO  command is like a "CALL" or "GOSUB" in that there can be
  1101.          nested .SO invokations;  one can access a file with  .SO  that
  1102.          contains in  turn  a  .SO command, etc.  It is a limitation of
  1103.          ROFF4 at present to not be able  to  handle  the  .so  command
  1104.          from keyboard  input (it could be useful).  The files, SOTEST,
  1105.          ONE, TWO, and THREE are provided to test and  demonstrate  the
  1106.          .SO command.
  1107.  
  1108.               All   file   names   referenced   by   .di  and  .so  are
  1109.          automatically treated as uppercase.   The  naming  conventions
  1110.          should conform  to  the  operating  system  (CP/M).    It is a
  1111.          limitation of the formatter at present  to  not  realize  that
  1112.          "A:ZZ" would  be  the  same  as "ZZ";  be sure to use the same
  1113.          form throughout!
  1114.  
  1115.               We shall present a detailed example of  the  use  of  the
  1116.          above   preprocessing   commands   to  automate  footnote  and
  1117.          reference numbering and collection.
  1118.  
  1119.  
  1120.  
  1121.                                                                    Page  17
  1122.  
  1123.  
  1124.     ROFF4 V1.61                                                Augest 3,1985
  1125.  
  1126.  
  1127.               We start by creating a register variable, "f#",  to  keep
  1128.          track of the current footnote number:
  1129.  
  1130.           .rg f# 1
  1131.  
  1132.               We  shall  use,  say,  "[15]"  as  our  means  to display
  1133.          reference numbering.    (We  could  have   used   superscripts
  1134.          instead with "^+15^-"):
  1135.  
  1136.           .ds "fn"[\\f#]"
  1137.  
  1138.          We  have used "\\" so that "fn" is defined as "[\f#\] and will
  1139.          be evaluated with the current footnote number at the  time  of
  1140.          use (not  of the time we nade this .ds definition).  By typing
  1141.          \fn\ we will get the reference in the form,  "[number]",  that
  1142.          we wanted.
  1143.  
  1144.               We  want  to  create a diversion, "FNOTES", into which we
  1145.          will place all our references.  The head of this file will  be
  1146.          titled with "REFERENCES":
  1147.  
  1148.           .di fnotes
  1149.           .ls 1
  1150.           .sp 1
  1151.           .ce 1
  1152.           REFERENCES
  1153.           .sp 2
  1154.           .ed
  1155.  
  1156.               The   diversion   will  contain  (hopefully)  a  list  of
  1157.          numbered footnotes.  To make the addition of  these  footnotes
  1158.          as  painless as possible, we define two macros, "FS" [footnote
  1159.          start] and "FE" [footnote end]:
  1160.  
  1161.           .dm FS
  1162.           .di fnotes
  1163.           .sp 1
  1164.           \\fn\\\\
  1165.           .em
  1166.                   and:
  1167.           .dm FE
  1168.           .ed
  1169.           .rg f# +1
  1170.           .em
  1171.  
  1172.  
  1173.               The FS macro skips a line and attaches the evaluation  of
  1174.          \fn\  to  the  start of the line that follows the macro during
  1175.          execution.  The  lines  that  follow  the  FS  macro  will  be
  1176.          diverted to  FNOTES.    The  FE macro terminates the diversion
  1177.          and, also, increments the footnote number, f#.
  1178.  
  1179.               We could try a very small piece of text now:
  1180.  
  1181.           .nf
  1182.           It is a nice day.\fn\
  1183.           .FS
  1184.           conventional expression.
  1185.  
  1186.  
  1187.                                                                    Page  18
  1188.  
  1189.  
  1190.     ROFF4 V1.61                                                Augest 3,1985
  1191.  
  1192.  
  1193.           .FE
  1194.           It's a crummy day.\fn\
  1195.           .FS
  1196.           unconventional!
  1197.           .FE
  1198.  
  1199.          The formatter will generate:
  1200.  
  1201.           It is a nice day.[1]
  1202.           It is a crummy day.[2]
  1203.  
  1204.          and the diversion file, FNOTES, will contain:
  1205.  
  1206.           .ls 1
  1207.           .sp 1
  1208.           .ce 1
  1209.           REFERENCES
  1210.           .sp 2
  1211.           .sp 1
  1212.           [1]conventional expression.
  1213.           .sp 1
  1214.           [2]unconventional!
  1215.  
  1216.          which, after formatting, will be:
  1217.  
  1218.  
  1219.                                   REFERENCES
  1220.  
  1221.  
  1222.  
  1223.          [1]conventional expression.
  1224.  
  1225.          [2]unconventional!
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.                                                                    Page  19
  1254.  
  1255.